package com.guizi.halftimesroom.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.guizi.halftimesroom.R;
import com.guizi.halftimesroom.bean.ActiveDrawerBean;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by Alan on 2016/7/20.
 */
public class PersonalCardView extends LinearLayout{
    private Context mContext;
    private CircleImageView cv_activity_illust;
    private TextView tv_personalcard;
    private ImageView iv_personalcard1,iv_personalcard2,iv_personalcard3;
    private List<ImageView>  list;

    public PersonalCardView(Context context) {
        this(context,null);
    }

    public PersonalCardView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public PersonalCardView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context context) {
        this.mContext=context;
        list= new ArrayList<>();
        View view = LayoutInflater.from(mContext).inflate(R.layout.view_personalcard, this);
        cv_activity_illust = (CircleImageView) view.findViewById(R.id.cv_activity_illust);
        tv_personalcard = (TextView) view.findViewById(R.id.tv_personalcard);
        iv_personalcard1 = (ImageView) view.findViewById(R.id.iv_personalcard1);
        iv_personalcard2 = (ImageView) view.findViewById(R.id.iv_personalcard2);
        iv_personalcard3 = (ImageView) view.findViewById(R.id.iv_personalcard3);
        list.add(iv_personalcard1);
        list.add(iv_personalcard2);
        list.add(iv_personalcard3);
    }

    public void setData(ActiveDrawerBean.DataBean bean){
        Picasso.with(mContext).load(bean.getAvatar()).into(cv_activity_illust);
        tv_personalcard.setText(bean.getUname());
        for (int i = 0; i <bean.getPosts().size() ; i++) {
            Picasso.with(mContext).load(bean.getPosts().get(i).getCover()).into(list.get(i));
        }
    }
}
